﻿#region
using System;
using System.Windows.Forms;
using Y2M.Components;
using Y2M.Properties;

#endregion

namespace Y2M.Forms
{
    public partial class SettingForm : Form
    {
        public SettingForm()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (DesignMode || RunTimeChecker.IsRunTime == false)
                return;

            txtBrowse.Text = Settings.Default.DownloadRoot;
            rdbAsAudio.Checked = Settings.Default.AudioOnly;
            rdbAsVideo.Checked = !Settings.Default.AudioOnly;
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            var dialog = new FolderBrowserDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
                txtBrowse.Text = dialog.SelectedPath;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;

            Settings.Default.AudioOnly = rdbAsAudio.Checked;
            Settings.Default.DownloadRoot = txtBrowse.Text;

            Settings.Default.Save();
        }
    }
}